<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回调函数</title>
    <!-- 引入 Bootstrap -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style>
        img{max-width: 650px;}
    </style>
</head>
<body class="container">
<h1>阻塞代码实例</h1>
<h3>创建app.js，内容如下：</h3>
<div class="well">
    <xmp>
        var fs=require("fs");
        var data=fs.readFileSync('app.js');
        console.log(data.toString());
        console.log('程序执行结束……');
    </xmp>
</div>
<h3>在cmd中运行效果如下：</h3>
<div class="well">
    <img src="20171112134908.png"/>
</div>
<h1>非阻塞代码实例 </h1>
<h3>创建app2.js，内容如下：</h3>
<div class="well">
    <xmp>
        var fs=require("fs");
        fs.readFile("app2.js",function (err,data) {
        if(err){
        return console.error(err);
        }
        console.log(data.toString());
        });
        console.log('程序执行结束……');
    </xmp>
</div>
<h3>在cmd中运行效果如下：</h3>
<div class="well">
    <img src="20171112135732.png"/>
</div>
</body>
</html>